// pages/index/index.js

Page({
  data:{
    
  },
   //分享功能
   onShareAppMessage:function(){
    return {
      title: '油菜花',
      desc: '油菜花',
      path: '/page/majar/majarlist'
    }
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    //console.log(options);
    this.loadMajorList({ majorCategoryId:options.majartypeId,pageNum: 1, pageSize: 10});
  },
  
  onReady:function(){
    // 页面渲染完成
   
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  },
  openMajorSchoolListWindow: function (e){
    console.log(e.currentTarget.dataset);
    wx.navigateTo({
      url: './majar_school_list?majorId=' + e.currentTarget.dataset.majorid,
    })
    //TODO 在这里加载数据
    
  },
  loadMajorList: function (requestObj){
    var self = this;
    wx.request({
      url: getApp().globalData.server + "/major/major_list.do",
      data: requestObj,
      header: {
        'Content-Type': 'application/json'
      },
      success: function (res) {
        if (res.data.status != 0) {
          wx.showToast({
            title: res.data.msg,
            icon: 'none',
            duration: 1000,
            mask: true
          })
        } else {
          console.log(requestObj);
          console.log(res.data);
          self.setData({
            majorList: res.data.data.list,
          });

        }

      },
      fail: function () {
        wx.showToast({
          title: "获取专业列表失败",
          icon: 'none',
          duration: 1000,
          mask: true
        })
      }
    })
  }
})